package Lesson02;

public class Demo_202 {
    public static void main(String[]args)throws Exception{
        Thread t1 = new Thread(()->{
            while (true){
                //打印线程名称
                System.out.println(Thread.currentThread().getName()+"hello thread...");
                try {
                    Thread.sleep(1000);
                }catch (InterruptedException e){
                    e.printStackTrace();
                }
            }
        });
        //启动t1
        t1.start();

        //指定线程名
        Thread t2 = new Thread(()->{
            while (true){
                //获取类名
                String cName = Demo_202.class.getName();
                //获取当前执行的方法名
                String mName = Thread.currentThread().getStackTrace()[1].getMethodName();
                //获取线程对象
                Thread thread =Thread.currentThread();
                //获取线程名
                String tName = thread.getName();
                System.out.println(thread);
            }
        });
    }
}
